/*
 * Stack.h
 *
 *  Created on: 2011-5-23
 *      Author: william nie
 */

#include<stdio.h>
#include<stdlib.h>
#include"datadef.h"

#ifndef STACK_H_
#define STACK_H_

#define STACK_INCREMENT 50

typedef int SElemType;

typedef struct SNode{
	SElemType* data;
} SNode;

typedef struct {
	SNode *base;
	SNode *top;
	int length;
	int size;
} Stack;

typedef BOOL (*StackVisit)(SNode *sNode);

Status InitStack(Stack **stack, int initSize);

Status DestroyStack(Stack **stack);

Status ClearStack(Stack *stack);

BOOL StackEmpty(Stack *stack);

int StackLength(Stack *stack);

SNode* GetTop(Stack *stack);

Status Push(Stack *stack, SElemType *elem);

SElemType* Pop(Stack *stack);

Status StackTraverse(Stack *stack, StackVisit visit);

/*****Nonstandard Functions*****/

Status FillStack(Stack *stack);

BOOL DefaultStackVisit(SNode *sNode);

#endif /* STACK_H_ */
